package org.hindusingles.thf.server;

import java.io.IOException;
import java.util.concurrent.TimeUnit;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.google.appengine.api.taskqueue.Queue;
import com.google.appengine.api.taskqueue.QueueFactory;
import com.google.appengine.api.taskqueue.TaskOptions;

@SuppressWarnings("serial")
public class EnqueueServlet extends HttpServlet
{
	public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException
	{
		response.setContentType("text/plain");
		response.getWriter( ).println("Adding tasks to queue.");
		
		Queue queue = QueueFactory.getQueue("noRetry");
		
		for (int i = 0; i < 3; i++)
		{
			queue.add
			(
				TaskOptions.Builder.withUrl("/insult").method(TaskOptions.Method.GET).countdownMillis(TimeUnit.SECONDS.toMillis(20))/**/
			);
		}
	}
}